<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template_layout_lr.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-button, .ui-button span, button.ui-button.ui-state-default span,
	.ui-button.ui-state-default span {
	font-weight: normal
}
</style>
	</ui:define>

	<ui:define name="left-box-title" style="border:0">
		保护分类<br/><br/>
		<p:autoComplete placeholder="输入设备型号可查询" id="in_station" style="font-size: 14px"
					completeMethod="#{protectionComponentLibraryController.completeDevType}" scrollHeight="400">
			<p:ajax event="itemSelect"  update="treeForm:tree  componentForm:componentTools  componentForm:componentTb"
							listener="#{protectionComponentLibraryController.locateDevType}" />
		</p:autoComplete>
		<p:commandButton icon="fa fa-refresh" style="margin-left: 3px;font-size: 14px" 
		actionListener="#{protectionComponentLibraryController.refresh}"
		value="刷新"
		update="treeForm:tree  componentForm:componentTools  componentForm:componentTb"
		title="刷新" />
	</ui:define>
	<ui:define name="left-box-body">
		<h:form id="treeForm" style="width:98% ;height:80%;">
			
			<p:panel  style="border:0;width:98% ;height:800px;">
				<p:tree value="#{protectionComponentLibraryController.root}" var="node" dynamic="true"
					id="tree" widgetVar="tree" animate="true" selectionMode="single" style="border:0">
					<p:ajax event="expand" update="tree componentForm:componentTools"
						listener="#{protectionComponentLibraryController.onNodeExpand}" />
					<p:ajax event="select"
						update="componentForm:componentTb componentForm:componentTools"
						listener="#{protectionComponentLibraryController.onNodeSelect}" />
					<p:treeNode type="manu" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="model" icon="fa fa-user-secret">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="model2" icon="fa fa-user-secret">
						<h:outputText value="#{node}" />
					</p:treeNode>
				</p:tree>
			</p:panel>
		</h:form>
	</ui:define>
	<ui:define name="right-box-title">
		动作元件明细
	</ui:define>
	<ui:define name="right-box-body">
		<h:form id="componentForm">
			<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
				<p:commandButton value="是" type="button"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="否" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>
			<p:growl id="componentMsg" showDetail="true" />
			<p:toolbar id="componentTools">
				<f:facet name="left">
					<p:commandButton value="新建" icon="ui-icon-plus" 
						actionListener="#{protectionComponentLibraryController.preCreate}" 
						disabled="#{protectionComponentLibraryController.currentSelect == null || protectionComponentLibraryController.currentSelect == ''}" 
						oncomplete="PF('componentDialog').show()" update="dialogForm" 
						rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_dzyjwh_xj')}" />
					<p:commandButton value="编辑" icon="ui-icon-pencil" 
						disabled="#{protectionComponentLibraryController.selected == null}" 
						oncomplete="PF('componentDialog').show()" update="dialogForm" 
						rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_dzyjwh_bj')}" />
					<p:commandButton value="删除" actionListener="#{protectionComponentLibraryController.deleteComponent}" 
						disabled="#{protectionComponentLibraryController.selected == null}"
						update="componentTb componentMsg componentTools" icon="ui-icon-trash" 
						rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_dzyjwh_sc')}">
						<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />	
					</p:commandButton>
				</f:facet>
			</p:toolbar>
			<p:dataTable id="componentTb" var="comp" rowKey="#{comp.id}" rowIndexVar="ite" draggableRows="true"
				value="#{protectionComponentLibraryController.componentList}" emptyMessage="没有记录"
				selection="#{protectionComponentLibraryController.selected}" 
				style="margin-bottom:20px" rows="20" paginator="true" paginatorPosition="bottom"
				paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="20,50,100">
				<f:facet name="{Customization}">
					<p:outputLabel value="总计：#{protectionComponentLibraryController.componentList.size()} 条记录"
						style="margin-right:20px;"></p:outputLabel>
				</f:facet>
				<p:ajax event="rowSelectRadio" listener="#{protectionComponentLibraryController.onRowSelect}" 
					update="componentForm:componentTools" />
			    <p:ajax event="rowReorder" listener="#{protectionComponentLibraryController.onRowReorder}" update="componentForm:componentTb" /> 
				<p:column selectionMode="single" style="width:40px;text-align:center" />
				<p:column width="5%" headerText="序号 ">
					<h:outputText value="#{ite+1}" />
				</p:column>
				<p:column headerText="动作元件">
					<h:outputText value="#{comp.actionComponent}" />
				</p:column>
				<p:column headerText="装置型号">
					<h:outputText value="#{comp.protectModel}" />
				</p:column>
				<p:column headerText="保护类型">
					<h:outputText value="#{comp.protectType}" />
				</p:column>
				<p:column headerText="关联条件">
					<h:outputText value="#{comp.relationCondition}" />
				</p:column>
				<p:column headerText="功能分类">
					<h:outputText value="#{comp.funClassification}" />
				</p:column>
				<p:column headerText="动作顺序">
					<h:outputText value="#{comp.actionOrder}" />
				</p:column>
			</p:dataTable>
		</h:form>
		<h:form id="dialogForm">
			<p:dialog widgetVar="componentDialog" header="新建" closable="true" resizable="false"
				draggable="false" modal="true" width="400" height="400">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" update="componentForm:componentTb componentForm:componentMsg componentForm:componentTools"
								oncomplete="PF('componentDialog').hide()"
								actionListener="#{protectionComponentLibraryController.saveComponent}" icon="ui-icon-disk" 
								rendered="#{s:hasPermission(session,'jcsj_sjwh_ecsbwh_dzyjwh_bc')}" />
					<!-- 		<p:commandButton icon="ui-icon-cancel" onclick="PF('componentDialog').hide()" value="取消"
								style="margin-left:5px" /> -->
						</f:facet>
					</p:toolbar>
					<p:panelGrid columns="2" cellpadding="4" style="width:100%;text-align:center">
						<h:outputText value="动作元件：" />
						<p:inputText style="width:100%" required="true" requiredMessage="动作元件必填项，不能为空"
							value="#{protectionComponentLibraryController.selected.actionComponent}">
						</p:inputText>
						<h:outputText value="装置型号：" />
						<p:inputText style="width:100%" required="true" requiredMessage="装置型号必填项，不能为空"
							value="#{protectionComponentLibraryController.selected.protectModel}">
						</p:inputText>
						<h:outputText value="保护类型：" />
						<p:inputText style="width:100%" required="true" requiredMessage="保护类型必填项，不能为空"
							value="#{protectionComponentLibraryController.selected.protectType}">
						</p:inputText>
						<h:outputText value="关联条件：" />
						<p:inputText style="width:100%" required="true" requiredMessage="关联条件必填项，不能为空"
							value="#{protectionComponentLibraryController.selected.relationCondition}">
						</p:inputText>
						<h:outputText value="功能分类：" />
						<p:inputText style="width:100%" required="true" requiredMessage="功能分类必填项，不能为空"
							value="#{protectionComponentLibraryController.selected.funClassification}">
						</p:inputText>
						 <h:outputText value="动作顺序：" />
						<p:inputText style="width:100%"
							value="#{protectionComponentLibraryController.selected.actionOrder}">
						</p:inputText> 
					</p:panelGrid>
				</p:dialog>
			</h:form>
	</ui:define>
</ui:composition>
